package com.fenghongzhang.a1811;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.NavigationCallback;
import com.alibaba.android.arouter.launcher.ARouter;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void btn(View view) {
//        Intent intent = new Intent(this, Main2Activity.class);

//        startActivity(intent);

        ARouter.getInstance().build("/main/main2")
                .withString("key","哈哈")
                .withInt("age",123)
                .withObject("user",new User("哈哈哈哈"))
                .navigation(this, new NavigationCallback() {
                    @Override
                    public void onFound(Postcard postcard) {
                        Log.i(TAG, "onFound:  "+postcard.toString());
                    }

                    @Override
                    public void onLost(Postcard postcard) {
                        Log.i(TAG, "onLost: ");
                    }

                    @Override
                    public void onArrival(Postcard postcard) {
                        Log.i(TAG, "onArrival: ");

                    }

                    @Override
                    public void onInterrupt(Postcard postcard) {
                        Log.i(TAG, "onInterrupt:啦啦啦 ");
                    }
                });

    }

    public void shop(View view) {
        ARouter.getInstance().build("/news/one")
                .withString("key","哈哈")
                .navigation();
    }
}
